import React from 'react';
import { Breadcrumb as AntBreadcrumb } from 'antd';
import { Link, useLocation } from 'react-router-dom';
import { getBreadcrumbs } from '../router/utils';

// 面包屑导航组件
const Breadcrumb: React.FC = () => {
  const location = useLocation();
  const breadcrumbs = getBreadcrumbs(location.pathname);

  return (
    <AntBreadcrumb className="breadcrumb">
      {breadcrumbs.map((item, index) => (
        <AntBreadcrumb.Item key={item.path}>
          {index === breadcrumbs.length - 1 ? (
            <span>{item.title}</span>
          ) : (
            <Link to={item.path}>{item.title}</Link>
          )}
        </AntBreadcrumb.Item>
      ))}
    </AntBreadcrumb>
  );
};

export default Breadcrumb; 